#ifndef __CORE_DELAY_H
#define __CORE_DELAY_H

#include "stm32f10x.h"

#define USE_DWT_DELAY			1	/* 浣跨敤dwt鍐呮牳绮剧‘寤舵椂 */

#if USE_DWT_DELAY
#define USE_TICK_DELAY		0		/* 涓嶄娇鐢⊿ysTick寤舵椂 */
#else
#define USE_TICK_DELAY		1		/* 浣跨敤SysTick寤舵椂 */
#endif


/*绠€鍗曚换鍔＄鐞*/
#define TASK_ENABLE 0
#define NumOfTask 3


#if USE_DWT_DELAY

#define Delay_ms(ms)  	CPU_TS_Tmr_Delay_MS(ms)
#define Delay_us(us)  	CPU_TS_Tmr_Delay_US(us)
/* 
*鏈€澶у欢鏃?60s=2鐨?2娆℃柟/72000000 */
#define Delay_s(s)  	  CPU_TS_Tmr_Delay_S(s)

/* 鑾峰彇鍐呮牳鏃堕挓棰戠巼 */
#define GET_CPU_ClkFreq()       (SystemCoreClock)
#define SysClockFreq            (SystemCoreClock)
/* 涓烘柟渚夸娇鐢紝鍦ㄥ欢鏃跺嚱鏁板唴閮ㄨ皟鐢–PU_TS_TmrInit鍑芥暟鍒濆鍖栨椂闂存埑瀵勫瓨鍣紝
   杩欐牱姣忔璋冪敤鍑芥暟閮戒細鍒濆鍖栦竴閬嶃€?   鎶婃湰瀹忓€艰缃负0锛岀劧鍚庡湪main鍑芥暟鍒氳繍琛屾椂璋冪敤CPU_TS_TmrInit鍙伩鍏嶆瘡娆￠兘鍒濆鍖?*/  

#define CPU_TS_INIT_IN_DELAY_FUNCTION   0


/*******************************************************************************
 * 							鍑芥暟澹版槑
 ******************************************************************************/
uint32_t CPU_TS_TmrRd(void);
void CPU_TS_TmrInit(void);

//浣跨敤浠ヤ笅鍑芥暟鍓嶅繀椤诲厛璋冪敤CPU_TS_TmrInit鍑芥暟浣胯兘璁℃暟鍣紝鎴栦娇鑳藉畯CPU_TS_INIT_IN_DELAY_FUNCTION
//鏈€澶у欢鏃跺€间负60绉?void CPU_TS_Tmr_Delay_US(uint32_t us);
#define CPU_TS_Tmr_Delay_MS(ms)     CPU_TS_Tmr_Delay_US(ms*1000)
#define CPU_TS_Tmr_Delay_S(s)       CPU_TS_Tmr_Delay_MS(s*1000)

#endif

#endif /* __CORE_DELAY_H */
